package org.example.easybuy.controller;

import org.example.easybuy.service.IndexService;
import org.example.easybuy.service.ProductService;
import org.example.easybuy.util.CustomResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class IndexController {

    @Autowired
    private ProductService productService;

    @Autowired
    private IndexService indexService;

    @GetMapping("/selectProductsById")
    public CustomResult selectProductsById(int id)
    {
        return CustomResult.successResult().addResult("products",productService.selectProductsById(id));
    }

    @GetMapping("/getEsProductPageInfo")
    public CustomResult getEsProductPageInfo(@RequestParam Map<String,String> map)
    {
        return CustomResult.successResult().addResult("pageInfo",indexService.getEsPageInfo(map));
    }
}
